#!/usr/bin/env node

const mysql = require('mysql2/promise');

let con = mysql.createPool({
  host:'localhost',
  user:'root',
  password:'ddd',
  database:'test'
});

async function addAreas(areaname){
  const sql = `insert into areas(area_name) values('${areaname}')`;
  let [rows] = await con.execute(sql);
  return rows;
}

async function delArea(areaname){
  cosnt sql = `delete from areas where area_name='${areaname}'`;
  let [rows] = await con.execute(sql);
  return rows;
}

async function updataAreas(old_name,new_name){
  const sql = `uodata areas set area_name='${new_name}' where area_name='${old_name}'`;
  let[rows] = await con.execute(sql);
  return rows;
}

async function getAreas(){
  const sql = 'select * from areas';
  let [rows] = await con.execute(sql);
  return rows;
}

(async function(){
 console.log(await getAreas());
})();
